﻿//全选取消按钮函数，调用样式如：
function checkAll(chkobj) {
    if ($(chkobj).find("span b").text() == "全选") {
        $(chkobj).find("span b").text("取消");
        $(".checkBox input").attr("checked", true);
    } else {
        $(chkobj).find("span b").text("全选");
        $(".checkBox input").attr("checked", false);
    }
}
//============================================================================================//
//表格隔行变色
$(function () {
    $(".msgtable tr:nth-child(odd)").addClass("tr_odd_bg"); //隔行变色
    $(".msgtable tr").hover(
			    function () {
			        $(this).addClass("tr_hover_col");
			    },
			    function () {
			        $(this).removeClass("tr_hover_col");
			    }
		    );
			});
//============================================================================================//
//Tab控制函数
function tabs(tabId, tabNum) {
	//设置点击后的切换样式
	$(tabId + " #Tab_nav li").removeClass("selected");
	$(tabId + " #Tab_nav li").eq(tabNum).addClass("selected");
	//根据参数决定显示内容
	$(tabId + " .Tab_Con").hide();
	$(tabId + " .Tab_Con").eq(tabNum).show();
}
//============================================================================================//
//形成遮罩层
//打开显示框
function show(strId) {
    document.getElementById(strId).style.display = 'block';
    var sWidth, sHeight;
    sWidth = parent.document.body.clientWidth;
    sHeight = parent.document.body.clientHeight;
    var bgObj = parent.document.createElement("div");
    bgObj.setAttribute('id', 'bgDiv');
    bgObj.style.position = "absolute";
    bgObj.style.top = "0";
    bgObj.style.left = "auto";
    bgObj.style.right = "auto";
    bgObj.style.background = "#777";
    bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
    bgObj.style.opacity = "0.6";
    bgObj.style.width = sWidth + "px";
    bgObj.style.height = sHeight + "px";
    document.body.appendChild(bgObj);
}
//关闭显示框
function hidd(strId) {
    document.getElementById(strId).style.display = 'none';
    document.getElementById('bgDiv').parentNode.removeChild(document.getElementById('bgDiv'));
}
//展示div
function showDiv(id) {
    document.getElementById(id).style.display = 'block';
}
//隐藏div
function hideDiv(id) {
    document.getElementById(id).style.display = 'none';
}

//单独上传文件
//参数为id
//================上传文件JS函数开始，需和jquery.form.js一起使用===============
//单个文件上传
function SingleUpload(repath, uppath, iswater) {
    var submitUrl = "../../tool/SingleUpload.ashx?ReFilePath=" + repath + "&UpFilePath=" + uppath;
    //判断是否打水印
    if (arguments.length == 3) {
        submitUrl = "../../tool/SingleUpload.ashx?ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater;
    }
    //开始提交
    $("#form1").ajaxSubmit({
        beforeSubmit: function (formData, jqForm, options) {
            //隐藏上传按钮
            $("#" + repath).nextAll(".files").eq(0).hide();
            //显示LOADING图片
            $("#" + repath).nextAll(".uploading").eq(0).show();
        },
        success: function (data, textStatus) {
            if (data.msg == 1) {
                $("#" + repath).val(data.msbox);
            } else {
                alert(data.msbox);
            }
            $("#" + repath).nextAll(".files").eq(0).show();
            $("#" + repath).nextAll(".uploading").eq(0).hide();
        },
        error: function (data, status, e) {
            if (data.msg == 1) {
                $("#" + repath).val(data.msbox);
            } else {
                alert(data.msbox);
            }
            $("#" + repath).nextAll(".files").eq(0).show();
            $("#" + repath).nextAll(".uploading").eq(0).hide();
        },
        url: submitUrl,
        type: "post",
        dataType: "json",
        timeout: 600000
    });
};